package utils

import (
	"encoding/json"
	"fmt"
)

func Throw(err error) {
	if err != nil {
		panic(err)
	}
}

func ToJsonString(data interface{}) string {
	return string(toJson(data))
}

func ToJsonBytes(data interface{}) []byte {
	return toJson(data)
}

func toJson(data interface{}) []byte {
	if data == nil {
		return nil
	}
	marshal, _ := json.Marshal(data)
	return marshal
}

func GetValuePointer[T any](value T) *T {
	return &value
}
func SqlLike(col *string) string {
	return fmt.Sprintf("%v", "%"+*col+"%")
}
